<% @page_title = "List all reserved books" %>
<%= stylesheet_link_tag "admin/list-items", :media => "all" %>
<style>
	.check img {
		box-shadow: none;
		height: 20px;
		width: 20px;
	}
	
	.check img:hover {
		box-shadow: none;
	}
</style>
<div class="list-users">
	<h1>List all reserved books</h1>
	<table>
		<tr>
			<th>ID</th>
			<th>Book</th>
			<th>Available</th>
			<th>Reserved Reader</th>
			<th>Reserved Date</th>
			<th>Is Checked</th>
			<th class='action'>Action</th>
		</tr>
		<% order = 0 %>
		<% @reserved_books.each do |rb| %>
			<tr <% if order % 2 == 0 %><%= "class='alt'" %><% end %> ><% order += 1 %>
				<td class='id'><%= rb.id %></td>
				<td><%= link_to rb.book.title, :controller => "admin/book", :action => "view", :id => rb.book.id %></td>
				<td><%= rb.book.free_quantity %></td>
				<td><%= link_to rb.user.fullname, :controller => 'admin/user', :action => 'view', :id => rb.user.id %></td>
				<td><%= rb.created_at %></td>
				<td class='check' style='text-align: center'>
					<% if rb.is_checked == 1 %>
						<%= image_tag('icons/checked-icon.png') %>
					<% else %>
						<%= image_tag('icons/not-checked-icon.png') %>
					<% end %>
				</td>
				<td class='action' style='text-align: center'>
					<%= link_to image_tag('icons/view-icon.png'), :controller => "admin/book_reserve", :action => "check", :id => rb.id %>&nbsp;
					<%= link_to image_tag('icons/delete-icon.png'), {:controller => "admin/book_reserve", :action => "delete", :id => rb.id}, :method => "delete", :data => {:confirm => "Are you sure?"} %>
				</td>
			</tr>
		<% end %>
	</table>
	<div class='paginator' style='margin-left:100px'><%= will_paginate @reserved_books %></div>
</div><!-- End .list-users -->
